package org.metasketch.simulator.runtime;

import java.util.HashMap;
import java.util.Map;
import org.metasketch.simulator.petri.PetriNet;

public class SimulationProcess {

	Long id;

	PetriNet initialPetriNet;

	PetriNetTraversal traversal;

	ResourcePool ownedResources = new ResourcePool();
	ResourcePool ownedActiveResources = new ResourcePool();

	ResourcePool assignedResources = new ResourcePool();
	ResourcePool AssignedActiveResources = new ResourcePool();

	Map<String, Object> attributes = new HashMap<String, Object>();

	ProcessManager processManager;

	public void terminate() {
		processManager.remove(this);

	}

	public void simulate(Long currentTime) throws Exception {
		if (traversal == null)
			traversal = new PetriNetTraversal(initialPetriNet, this);

		traversal.simulate(currentTime);

	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public PetriNet getInitialPetriNet() {
		return initialPetriNet;
	}

	public void setInitialPetriNet(PetriNet petriNet) {
		this.initialPetriNet = petriNet;
	}

	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	public ResourcePool getAssignedResources() {
		return assignedResources;
	}

	public void setAssignedResources(ResourcePool assignedResources) {
		this.assignedResources = assignedResources;
	}

	public ResourcePool getOwnedResources() {
		return ownedResources;
	}

	public void setOwnedResources(ResourcePool ownedResources) {
		this.ownedResources = ownedResources;
	}

	public ResourcePool getOwnedActiveResources() {
		return ownedActiveResources;
	}

	public void setOwnedActiveResources(ResourcePool activeResources) {
		this.ownedActiveResources = activeResources;
	}

	public void setProcessManager(ProcessManager processManager) {
		this.processManager = processManager;

	}

	public PetriNetTraversal getTraversal() {
		return traversal;
	}

	public void setTraversal(PetriNetTraversal traversal) {
		this.traversal = traversal;
	}

	public ResourcePool getAssignedActiveResources() {
		return AssignedActiveResources;
	}

	public void setAssignedActiveResources(ResourcePool assignedActiveResources) {
		AssignedActiveResources = assignedActiveResources;
	}

	public ProcessManager getProcessManager() {
		return processManager;
	}

}
